//
//  VideoViewController.m
//  Vision
//
//  Created by dllo on 16/3/12.
//  Copyright © 2016年 yue_zhang. All rights reserved.
//

#import "VideoViewController.h"
#import "PopAnimation.h"
#import "PlayerViewController.h"
#import <AVKit/AVKit.h>
#import "SelectedViewController.h"

@interface VideoViewController ()<UINavigationControllerDelegate>

@property (weak, nonatomic) IBOutlet UIImageView *contentLabel;

@end

@implementation VideoViewController

- (void)viewWillAppear:(BOOL)animated {
    self.navigationController.delegate = self;
    self.backScrollView.bounces = NO;
}

#pragma mark <UINavigationControllerDelegate>
- (id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
                                   animationControllerForOperation:(UINavigationControllerOperation)operation
                                                fromViewController:(UIViewController *)fromVC
                                                  toViewController:(UIViewController *)toVC{
    if ([toVC isKindOfClass:[SelectedViewController class]]) {
        PopAnimation *popAnimation = [[PopAnimation alloc]init];
        return popAnimation;
    }else{
        return nil;
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 30)];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.font = [UIFont fontWithName:@"Lobster 1.4" size:25];
    titleLabel.text = @"Vision";
    self.navigationItem.titleView = titleLabel;
    
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:self.data.cover[@"detail"]] placeholderImage:[UIImage imageNamed:@"selectedPlaceImage"]];
    [self.contentLabel sd_setImageWithURL:[NSURL URLWithString:self.data.cover[@"blurred"]] placeholderImage:[UIImage imageNamed:@"selectedPlaceImage"]];
}

- (IBAction)playbutton:(id)sender {
    self.hidesBottomBarWhenPushed = YES;
    PlayerViewController *playerVC = [[PlayerViewController alloc] init];
    playerVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    playerVC.playUrl = self.data.playUrl;
//    [self.navigationController pushViewController:playerVC animated:YES];
    [self presentViewController:playerVC animated:YES completion:^{
        
    }];
    NSLog(@"%@", self.data.playUrl);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}




@end
